<template>
	<om-formsub-outer :index="index" :checkedit="checkedit">
		<om-autoform ref="autoform" :edit="edit" :checkedit="checkedit" :initConfigData="autoformdata" :initValue="initValue"></om-autoform>
	</om-formsub-outer>
</template>

<script>
	import {
		buildSubFormData,
		subOnLoad,
		changeEditor,
		configSelectData
	} from '../../../static/js/formUtil.js';
	import {
		ignoreHtml,
		ptFloat,
		minusF,
		getDateStr
	} from '@/static/js/common.js';
	import urlUtil from '@/static/js/urlUtil.js';
	import  moment from "@/static/js/moment.js"
	export default {
		provide() {
			return {
				formPage: this
			};
		},
		data() {
			return buildSubFormData({
				
			})
		},
		methods:{
			onInputMonth1Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month1Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth2Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month2Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth3Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month3Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth4Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month4Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth5Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month5Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth6Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month6Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth7Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month7Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth8Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month8Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth9Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month9Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth10Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month10Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth11Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month11Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			onInputMonth12Code(value){
				let _that = this
				_that.$refs.autoform.formdata.month12Name =  value + _that.$refs.autoform.formdata.indexUnitName
			},
			initLoad(){
				let _that = this
				let arr = [
						_that.om.request(
							'torgAnnualTargetPlan/verifyQuarter',
							{
								indexId:_that.formdata.indexId
							}
						)
					]
				Promise.all(arr).then(res=>{
					if(res[0].value){
						for(let i = 1;i<5;i++){
							_that.$refs.autoform.changeEditor('title_after','quarter'+i+'Code','type','numberbox')
							_that.$refs.autoform.changeEditor('title_after','quarter'+i+'Code',"digit",true)
						}
					}
					//大于等于当前月份开放编辑
					let month = moment().month()
					for(let index = 0; index<12;index++){
						if(index+1 > month){
							_that.$refs.autoform.changeEditor('title_after',"month"+(index+1)+"Code","digit",true)
							_that.$refs.autoform.changeEditor("title_after","month"+(index+1)+"Code","type","numberbox")
							_that.$refs.autoform.changeEditor("title_after","month"+(index+1)+"Code","suffix",_that.formdata.indexUnitName)
							_that.$refs.autoform.changeEditor("title_after","month"+(index+1)+"Code","suffixCol",_that.formdata.indexUnitName.length)
							_that.$refs.autoform.changeEditor("title_after","month"+(index+1)+"Code","prompt",'请输入')
						}
					}
				})
			},
			
		},
		onLoad(e) {
			let _that = this
			subOnLoad(_that, e, function() {
				if (e.configDataCacheKey) {
					uni.getStorage({
						key: e.configDataCacheKey,
						success: function(res) {
							//if (res.data && res.data instanceof Array) {
							if(res.data && Object.prototype.toString.call(res.data)==='[object Array]'){
								_that.autoformdata = res.data
							}
							Object.assign(_that.initValue, _that.formdata)
							_that.autoformdata[0].order = _that.order
							changeEditor("title_after","targetValueCode","prefix",_that.formdata.logicRelationshipName,_that.autoformdata)
							changeEditor("title_after","targetValueCode","suffix",_that.formdata.indexUnitName,_that.autoformdata)
							changeEditor("title_after","targetValueCode","suffixCol",_that.formdata.indexUnitName.length,_that.autoformdata)
							changeEditor("title_after","targetValueCode","digit",true,_that.autoformdata)
							_that.initLoad()
						}
					})
				}
			})
		},
		onShow() {
			let _that = this
			if (_that.$refs.autoform) {
				
			}
		}
	}
</script>

<style>
</style>
